package com.jyb.qiyefuwu.view.activity;


import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jyb.qiyefuwu.R;
import com.jyb.qiyefuwu.databinding.ActivityTestServiceBinding;
import com.jyb.qiyefuwu.router.PathHome;
import com.jyb.qiyefuwu.uitls.CommPagerAdapter3;
import com.jyb.qiyefuwu.view.fragment.usercenter.ServiceAiAttentionFragment;
import com.jyb.qiyefuwu.viewmodel.ServiceTypeModel;
import com.swgk.core.common.base.BaseActivity;

import java.util.ArrayList;

@Route(path = PathHome.ServiceTestActivity)
public class TestServiceActivity extends BaseActivity<ServiceTypeModel, ActivityTestServiceBinding> {
    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private String[] type = new String[]{"知产", "服务", "需求"};
    private int index = 0;

    @Override
    protected int layoutId() {
        return R.layout.activity_test_service;
    }

    @Override
    protected void createViewModel() {
        mViewModel = new ViewModelProvider(this).get(ServiceTypeModel.class);
    }

    @Override
    protected void init() {
        mFragments.add(ServiceAiAttentionFragment.newInstance());
        mFragments.add(ServiceAiAttentionFragment.newInstance());
        mFragments.add(ServiceAiAttentionFragment.newInstance());
        CommPagerAdapter3 pagerAdapter = new CommPagerAdapter3(getSupportFragmentManager(), mFragments, type);
        mBinding.viewpager.setOffscreenPageLimit(type.length);
        mBinding.viewpager.setAdapter(pagerAdapter);
        mBinding.tabLayout.setupWithViewPager(mBinding.viewpager);
        mBinding.tabLayout.getTabAt(index).select();
    }
}
